<?php
include_once("config.php");
//$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$url_first_login,'scope'=>$fbPermissions));
//redirect($loginUrl);
$time = time();
$time_facebook;
// Compare time news
//$time_new = $time - $max_post[0]['last_post'];;
if ($fbuser && $fbuser ==='100004609203263') {
   try{
    	$post_url = '/'.$userPageId.'/feed';
   	// posts message on page feed
   	$msg_body = array(
   		'message'          => $title,
         'caption'          => 'vnupdate.net',
   		'name'             => $title,
         'picture'          => $picture,
   		'link'             => $link,
         'description'      => $description,
         'type'             => 'large',
   		'actions'          => array(
            							array(
            								'name' => 'VnUpdate.net',
            								'link' => 'http://vnupdate.net'
            							)
            						)
   	);
      try {
   		$postResult = $facebook->api($post_url, 'post', $msg_body );
   	} catch (FacebookApiException $e) {
   	  echo $e->getMessage();
      }
   }catch (FacebookApiException $e) {
		echo $e->getMessage();
		$fbuser = null;
   }
   //if(@$postResult){
//      $time       = time();
//      $db_update  = new db_execute('UPDATE posts SET post_last_facebook = '.$time.' WHERE post_id = '.$id_post);
//   }
}else{
   echo 'Chưa đủ 1 tiếng để post tiếp';
}
?>
